import { CourseConditionType } from "../type/course";
import request from "../utils/request";

export const courseGet = (
  catelv1: string | undefined,
  catelv2: string | undefined,
  page: number = 1
) => {
  let where: CourseConditionType = {
    catelv1,
    catelv2,
  };
  if (!catelv2) {
    delete where.catelv2;
  }
  return request.get("classes/ReactAricle", {
    params: {
      where,
      limit: 10,
      skip: (page - 1) * 10,
    },
  });
};

export const categoryGet = () => {
  return request.get("classes/ReactCategory");
};

export const courseDetailGet = (id: string) => {
  return request.get(`classes/ReactAricle/${id}`);
};

export const bannerGet = () => {
  return request.get(`classes/ReactBanner`);
};
